package main

import (
    "database/sql"
    "fmt"
    "log"
    //"os"

    "github.com/go-sql-driver/mysql"
)

var db *sql.DB

func main(){
    // db settings
    cfg := mysql.Config {
        User: "root",
        Passwd: "root",
        Net: "tcp",
        Addr: "127.0.0.1:3306",
        DBName: "earthworm",
    }
    
    var err error
    db, err = sql.Open("mysql", cfg.FormatDSN())

    if err != nil {
        log.Fatal(err)
    }

    pingErr := db.Ping()

    if pingErr != nil{
        log.Fatal(pingErr)
    }

    fmt.Println("Connected")
}
